<div class="layuimini-container layui-anim layui-anim-upbit">
    <div class="layuimini-main">

        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend>填写申请</legend>
        </fieldset>

        <form class="layui-form">
        
        	<div class="layui-form-item">
                <label class="layui-form-label">请假类型</label>
                <div class="layui-input-block">
                    <select id="leaveType" name="leave_type" lay-filter="aihao">
                       	<option value="事假">事假</option>
						<option value="病假">病假</option>
						<option value="年假">年假</option>
						<option value="丧假">丧假</option>
						<option value="产假">产假</option>
                    </select>
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">开始时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="start_time" id="stime" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                </div>
            </div>
            
            <div class="layui-form-item">
                <label class="layui-form-label">结束时间</label>
                <div class="layui-input-inline">
                    <input type="text" name="end_time" id="etime" lay-verify="date" placeholder="yyyy-MM-dd" autocomplete="off" class="layui-input">
                </div>
            </div>
            
            
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">请假原因</label>
                <div class="layui-input-block">
                    <textarea id="reason" name="reason" placeholder="请输入内容" class="layui-textarea"></textarea>
                </div>
            </div>
            
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn" id="applyBtn" lay-submit="" lay-filter="startLeave">开始申请</button>
                    <button type="reset" id="resetBtn" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>

    </div>
</div>
<script>
    layui.use(['form','laydate'], function () {
    	var $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer
            , laydate = layui.laydate;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();

        //日期
        laydate.render({
            elem: '#stime'
        });
        laydate.render({
            elem: '#etime'
        });
        
        
         //监听提交
        form.on('submit(startLeave)', function (data) {
        	$.post("startLeave?leave_type="+$("#leaveType").val()+"&start_time="+$("#stime").val()+"&end_time="+$("#etime").val()+"&reason="+$("#reason").val(),function(){
	    		 layer.msg("成功");
	    		 $("#resetBtn").click();
	    	});
	    	return false;
        });
        
    });
</script>